---@class DialogBaseCtr : IMediator
---@field protected data ObjData
---@field protected view DialogBaseView
local this = class("DialogBaseCtr", IMediator);

---@param args table
function this:Awake(args)
    self.super:Awake(args);
    self.mono = self.view.behaviour;

    LuaHelper.AddObjClick(self.mono.Close_obj, self.OnClick)
    LuaHelper.AddObjClick(self.mono.Dialog1_obj, self.OnClick)
    LuaHelper.AddObjClick(self.mono.Dialog2_obj, self.OnClick)
end

function this:Open()
    self.view:SetData(self.data);
    self.super:Open();
end

function this:Destroy()
    self.mono = nil;
    self.super:Destroy();
end

function this:PanelId()
    return PanelID.DialogBasePanel;
end

---@param go UnityEngine.GameObject
function this:OnClick(go)
    self:Close();
    if (go == self.mono.Dialog1_obj)then
        self:ClickCallBack(1);
    elseif (go == self.mono.Dialog2_obj)then
        self:ClickCallBack(2);
    end
end

---@param idx number
function this:ClickCallBack(idx)
    if(self.data and self.data.callArg)then
        local callBack = self.data.callArg[idx];
        if (callBack)then callBack(); end
    end
end

return this;